__author__ = 'vavava'

def parse_argvs(argvs):
    """
    usage:
        argv_dic=util.parse_argvs(argv)
        if argv_dic:
            if argv_dic.get('-ids'):  userTokens=argv_dic.get('-ids').split('|')
            if argv_dic.get('-d'):  httpdebuglevel=argv_dic.get('-d')
            if argv_dic.get('-t'):  socket_timeout=argv_dic.get('-t')
    """

    if len(argvs)<=1:
        return
    argv_dic={}
    key=None
    for each in argvs:
        if each.find('-') == 0:
            key=each
        else:
            if key is not None:
                argv_dic[key]=each
                key=None
    if key is not None:
        argv_dic[key]=key
    return argv_dic


def assure_path(path):
    import os.path
    if os.path.isdir(path) is not True:
        os.makedirs(path)

""" 如何判断平台类型
def TestPlatform():
    import platform
    #Windows will be : (32bit, WindowsPE)
    #Linux will be : (32bit, ELF)
    print(platform.architecture())

    #Windows will be : Windows-XP-5.1.2600-SP3 or Windows-post2008Server-6.1.7600
    #Linux will be : Linux-2.6.18-128.el5-i686-with-redhat-5.3-Final
    print(platform.platform())

    #Windows will be : Windows
    #Linux will be : Linux
    print(platform.system())

    #Windows and Linux will be : 3.1.1 or 3.1.3
    print(platform.python_version())

def UsePlatform():
    import platform
    sysstr = platform.system()
    if(sysstr =="Windows"):
        print ("Call Windows tasks")
    elif(sysstr == "Linux"):
        print ("Call Linux tasks")
    else:
        print ("Other System tasks")

"""
if __name__ == '__main__':
    import re
    m= re.findall(r'(^\s*$)','74.125.128.103  www.google.com.hk\n',re.MULTILINE)
    #m= re.findall(r'\s+(plus\.google\.com)\s*$','74.125.229.161  plus.google.com\n')
    if m:
        print(m)
    pass

